{% extends 'home_page/base_index.html' %}
{% load static %}


{% block show_sidebar %}
    {% if user_label == 2 %}
        {#  企业主页  #}
        <li class="sidebar-item active">
            <a href="{% url 'organization:home' %}" class='sidebar-link'>
                <i class="bi bi-grid-fill"></i><span>主页</span></a>
        </li>
        {# 企业发布就业信息 #}
        <li class="sidebar-item  ">
            <a href="{% url 'organization:post_jobs' %}" class="sidebar-link">
                <i class="bi bi-grid-1x2-fill"></i><span>发布就业岗位</span>
            </a>
        </li>
        {# 企业面试预约 #}
        <li class="sidebar-item  ">
            <a href="" class="sidebar-link">
                <i class="bi bi-grid-1x2-fill"></i><span>面试预约</span>
            </a>
        </li>
    {% elif user_label == 1 %}
        {#  学生主页  #}
        <li class="sidebar-item active ">
            <a href="{% url 'student:home' %}" class='sidebar-link'>
                <i class="bi bi-grid-fill"></i><span>主页</span></a>
        </li>
        {# 学生岗位信息 #}
        <li class="sidebar-item">
            <a href="" class="sidebar-link">
                <i class="bi bi-people-fill"></i><span>就业岗位</span>
            </a>
        </li>
        {# 学生面试预约 #}
        <li class="sidebar-item">
            <a href="" class="sidebar-link">
                <i class="bi bi-grid-1x2-fill"></i><span>面试预约</span>
            </a>
        </li>
        {# 学生实习状态 #}
        <li class="sidebar-item">
            <a href="" class="sidebar-link">
                <i class="bi bi-stack"></i><span>实习状态</span>
            </a>
        </li>
    {% endif %}
{% endblock %}


{% block page_head %}
    {% if user_label == 1 %}
        <div class="row">
            <div class="col-6 col-lg-3 col-md-6">
                <div class="card">
                    <div class="card-body px-3 py-4-5">
                        <div class="row">
                            <div class="col-md-4">
                                <div class="stats-icon purple"><i class="iconly-boldShow"></i></div>
                            </div>
                            <div class="col-md-8 d-flex align-items-center">
                                <h5 class="text-muted font-semibold">
                                    <a href="{% url 'student:show_jobs' %}">就业岗位</a>
                                </h5>
                                <h6 class="font-extrabold mb-0" id="teacher_count"></h6></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-6 col-lg-3 col-md-6">
                <div class="card">
                    <div class="card-body px-3 py-4-5 d-flex align-items-center">
                        <div class="row">
                            <div class="col-md-4">
                                <div class="stats-icon blue"><i class="iconly-boldProfile"></i></div>
                            </div>
                            <div class="col-md-8 d-flex align-items-center">
                                <h5 class="text-muted font-semibold"><a href="{% url 'student:home' %}">个人信息</a>
                                </h5>
                                <h6 id="student_count" class="font-extrabold mb-0"></h6>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-6 col-lg-3 col-md-6">
                <div class="card">
                    <div class="card-body px-3 py-4-5">
                        <div class="row">
                            <div class="col-md-4">
                                <div class="stats-icon green"><i class="iconly-boldAdd-User"></i></div>
                            </div>
                            <div class="col-md-8 d-flex align-items-center"><h5 class="text-muted font-semibold"><a
                                    href="">面试预约</a></h5>
                                <h6 class="font-extrabold mb-0" id="org_count"></h6></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-6 col-lg-3 col-md-6">
                <div class="card">
                    <div class="card-body px-3 py-4-5">
                        <div class="row">
                            <div class="col-md-4">
                                <div class="stats-icon red"><i the="iconly-boldBookmark"></i></div>
                            </div>
                            <div class="col-md-8 d-flex align-items-center"><h5 class="text-muted font-semibold"><a
                                    href="">实习状态</a></h5>
                                <h6 class="font-extrabold mb-0" id="apt_count"></h6></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    {% elif user_label == 2 %}
        <div class="row">
            <div class="col-6 col-lg-3 col-md-6" style="width: 50%">
                <div class="card">
                    <div class="card-body px-3 py-4-5">
                        <div class="row">
                            <div class="col-md-4">
                                <div class="stats-icon purple"><i class="iconly-boldBookmark"></i></div>
                            </div>
                            <div class="col-md-8 d-flex align-items-center">
                                <h5 class="text-muted font-semibold">
                                    <a href="{% url 'organization:post_jobs' %}">就业岗位</a>
                                </h5>
                                <h6 class="font-extrabold mb-0" id="teacher_count"></h6></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-6 col-lg-3 col-md-6" style="width: 50%">
                <div class="card">
                    <div class="card-body px-3 py-4-5">
                        <div class="row">
                            <div class="col-md-4">
                                <div class="stats-icon blue"><i class="iconly-boldActivity"></i></div>
                            </div>
                            <div class="col-md-8 d-flex align-items-center">
                                <h5 class="text-muted font-semibold"><a href="">面试预约</a></h5>
                                <h6 id="student_count" class="font-extrabold mb-0"></h6>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    {% endif %}


{% endblock %}

{% block show_body %}
<section class="section">
    <div class="row">
        <div class="col-xl-12 col-md-12 col-sm-12">
            <div class="card">
                <div class="card-content">
                    <div class="card-body">
                        <h4 class="card-title">{{ job.title }}&nbsp&nbsp&nbsp&nbsp{{ job.salary_range }}</h4>
                        <h6 class="card-subtitle"><a id="subscribe" href="{% url 'student:subscribe' %}?org_name={{ org.name }}">{{ org.name }}</a></h6>
                    </div>
                    <div class="card-body">
                        <h6 class="card-subtitle">职位描述</h6>
                        <p class="card-text">
                            {{ job.description }}
                        </p>
                        <p class="card-text">
                            {{ job.requirements }}
                        </p>
                    </div>
                    <div class="card-body">
                        <h6 class="card-subtitle">工作地点</h6>
                        <p class="card-text">
                            {{ job.location }}&nbsp&nbsp&nbsp&nbsp截止日期：{{ job.deadline }}
                        </p>
                    </div>
                </div>
            </div>
            <div class="card">
                <div class="card-content">
                    <div class="card-body">
                        <h4 class="card-title">面试预约</h4>
                        <p class="card-text">
                            输入您的姓名和电话号码等信息，我们将会与您联系。
                        </p>
                        <form id="form" class="form">
                            {% csrf_token %}
                            <div class="form-body">
                                <div class="form-group">
                                    <label for="feedback1" class="sr-only">姓名</label>
                                    <input required
                                        type="text" id="feedback1" class="form-control" placeholder="Name"
                                        name="stu_name">
                                </div>
                                <div class="form-group">
                                    <label for="feedback4" class="sr-only">电话号码</label>
                                    <input type="text" id="feedback4" class="form-control" required
                                                       placeholder="Phone Number" name="phone_number">
                                </div>
                                <div class="form-group">
                                    <label for="feedback2" class="sr-only">Email</label>
                                    <input type="email" id="feedback2" class="form-control" placeholder="Email"
                                        name="email" required>
                                </div>
                                <div class="form-group">
                                    <label for="gender" class="sr-only">性别</label>
                                    <select name="gender" class="form-control" id="gender" required>
                                        <option value="男" selected>男</option>
                                        <option value="女">女</option>
                                    </select>
                                </div>
                                <div class="form-group form-label-group">
                                    <label for="label-textarea" class="sr-only">自我介绍</label>
                                    <textarea class="form-control" id="label-textarea" rows="3" placeholder="Suggestion">

                                    </textarea>
                                    <label for="label-textarea"></label>
                                </div>
                                <input type="text" value="{{ job.id }}" name="job_id" hidden="hidden">
                            </div>
                            <div class="form-actions d-flex justify-content-end">
                                <button type="submit" class="btn btn-primary me-1">立即联系</button>
                                <button type="reset" class="btn btn-light-primary">取消</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
{% endblock %}


{% block show_user %}
    {% if user_label == 1 %}
        {# 当学生用户登录的时候显示学生的姓名和学号 #}
        <div class="card">
            <div class="card-body py-4 px-5">
                <div class="d-flex align-items-center">
                    {# 性别不同默认头像不一样 #}
                    <div class="avatar avatar-xl">
                        {% if gender == 'female' %}
                            <img src="{% static 'picture/5.jpg' %}" alt="Face female">
                        {% else %}
                            <img src="{% static 'picture/2.jpg' %}" alt="Face male">
                        {% endif %}
                    </div>
                    {# 加载学生的姓名和学号 #}
                    <div class="ms-3 name"><h5 class="font-bold">姓名：{{ student.stu_name }}</h5>
                        <h6 class="text-muted mb-0">
                            学号：{{ request.session.user_id }}
                        </h6>
                    </div>
                </div>
            </div>
        </div>
    {% elif user_label == 2 %}
        {# 当企业登录的时候显示组织的名称和账号 #}
        <div class="card">
            <div class="card-body py-4 px-5">
                <div class="d-flex align-items-center">
                    <div class="avatar avatar-xl">
                        <img src="{% static 'picture/5.jpg' %}" alt="Face female">
                    </div>
                    {# 加载企业的姓名和学号 #}
                    <div class="ms-3 name"><h5 class="font-bold">名称：{{ organization.name }}</h5>
                        <h6 class="text-muted mb-0">
                            账号：{{ request.session.user_id }}
                        </h6>
                    </div>
                </div>
            </div>
        </div>
    {% endif %}




{% endblock %}


{% block script_block %}
<script>
    $(document).ready(function() {
        $('#form').on('submit', function(e) {
            e.preventDefault();
            $.ajax({
                type: 'POST',
                url: "{% url 'student:create_interview' %}",
                data: $(this).serialize(),
                success: function(response) {
                    console.log(response);
                    if (response.code === 200) {
                        alert('预约成功');
                        window.location.href = "{% url 'student:show_jobs' %}";
                    } else {
                        alert('预约失败');
                        window.location.href = "{% url 'student:show_jobs' %}";
                    }
                },
                error: function(error) {
                    console.error('提交失败:', error);
                }
            });
        });
    });
</script>
    
{% endblock %}

